package com.xuyiwei.mayi.test;

/**
 * Created by xuyiwei on 2019/5/6.
 */
public class ThreadInterrupt implements Runnable{

    @Override
    public void run() {
        try {
            System.out.println("线程进入睡眠期");
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            System.out.println("线程睡眠期被打断");
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        ThreadInterrupt threadInterrupt = new ThreadInterrupt();
        Thread t = new Thread(threadInterrupt);
        t.start();
        t.interrupt();
    }
}
